<?php
	$page = $_GET['page'];
	
	switch($page){
		default:
			home();
			break;
		case "request_account":
			request_account();
			break;
		case "forgot_password":
			forgot_password();
			break;
		case "logout":
			logout();
			break;
		case "my_account":
			validating_authentication();
			my_account();
			break;
		case "reservation":
			validating_authentication();
			include ("system/scheduler.php");
			break;
		case "my_reservations":
			validating_authentication();
			include ("system/getUserReservations.php");
			break;
		case "manager_island":
			validating_authentication('admin');
			manager_island();
			break;
		case "add_island":
			validating_authentication('admin');
			add_island();
			break;
		case "edit_island":
			validating_authentication('admin');
			edit_island();
			break;
	}
		
	function home(){
		echo "<div id='text'>
				<a class='title'>FIBRE Testbed Access</a>
				<a>Welcome to the main access to FIBRE Testbed.</a>
				
				<a>This page gives access to a remote experimental infrastructure (or testbed) for tests with computer networks and distributed systems.</a>
				
				<a>The main goal of the FIBRE project is the design, implementation and validation of a shared Future Internet research facility, supporting the joint experimentation of European and Brazilian researchers. In order to achieve this goal the project will carry out four main activities:</a>
				<a>• The development and operation of a new experimental facility in Brazil, including the setup of equipment to support experimentation with various technologies (fixed layer 2 and layer 3, wireless, optical) as well as the design and implementation of a control framework to automate the use and operation of the testbed.</a>
				<a>• The development and operation of a Future Internet facility in Europe based on enhancements and the federation of two existing infrastructures: OFELIA and OneLab. Two OFELIA islands (i2CAT and UEssex) and the UTH's NITOS testbed will be enhanced by i) adding more physical resources (servers, OpenFlow-enabled switches and access points) to be able to cope with a bigger number of users and different use cases, ii) improving its respective control frameworks (based on the OFELIA control framework and OMF) and iii) adding more manpower to operate the facilities.</a>
				<a>• The federation of the Brazilian and European experimental facilities, both at the physical connectivity and control framework level, to support the provisioning of slices using resources from both testbeds.</a>
				<a>• The design and implementation of pilot applications of public utility that showcase the power of a shared Europe-Brazil Future Internet experimental facility.</a>
			</div>
		";
	}
	
	function my_account(){
		$ldap_connection = ldap_connect(HOST_LDAP,PORT_LDAP) or die("Error connecting to the LDAP server");
				
		ldap_set_option($ldap_connection, LDAP_OPT_PROTOCOL_VERSION, 3);
		ldap_set_option($ldap_connection, LDAP_OPT_REFERRALS, 0);
		
		if(isset($_POST['sbmt'])){
			$username = $_POST['username'];
			$name = $_POST['name'];
			$email = $_POST['email'];
			$current_password = $_POST['current_password'];
			$password = $_POST['password'];
			$password2 = $_POST['password2'];
			
			if(empty($username) || empty($name) || empty($email))
				set_message('Fill out all fields to continue.','alert',1);
			else{
				$institution = "".substr($username, strpos($username, "@")+1)."";
				$organization = "o=".substr($username, strpos($username, "@")+1)."";
				$organization = str_replace(".br","",$organization);
				
				require("mysql_connection.php");
				$ldap_server = mysql_query("SELECT `ldap_ip_address` FROM ".DB_SCHEDULER.".`islands` WHERE `institution` = '".$institution."'") or print_r(mysql_error());
				$ldap_server = mysql_fetch_object($ldap_server);
				
				$ldap_connection_island = ldap_connect($ldap_server->ldap_ip_address,PORT_LDAP) or die("Error connecting to the LDAP server of island");
				
				ldap_set_option($ldap_connection_island, LDAP_OPT_PROTOCOL_VERSION, 3);
				ldap_set_option($ldap_connection_island, LDAP_OPT_REFERRALS, 0);
				
				$ldap_bind = ldap_bind($ldap_connection_island, ISLAND_USER_LDAP, ISLAND_PASS_LDAP);

				$change = array(
							"sn" => array($name),
							"mail" => array($email)
						  );
						  
				// Change password:
				if(!empty($password) && !empty($password2) && ($password != $password2)){
					set_message('Passwords do not match.','alert',1);
					$password_error = TRUE;
				}else if(!empty($current_password) && !empty($password) && !empty($password2)){
					// search my current password
					$search_for = 'uid='.$username.'';		
					$search = ldap_search($ldap_connection, "".$_SESSION[''.SECURITY_SESSION.'']['organization'].",".LDAP_TREE."", $search_for);
					$ldapResults = ldap_get_entries($ldap_connection, $search);
					
					$current_password = '{CRYPT}'.md5crypt($current_password, substr($ldapResults[0]['userpassword'][0],7,12)).'';
					$password_verify = ldap_compare($ldap_connection, "uid=".$username.",".LDAP_PEOPLE.",".$_SESSION[''.SECURITY_SESSION.'']['organization'].",".LDAP_TREE."", 'userpassword', $current_password);
					
					if($password_verify == 1){
						$password = '{CRYPT}'.md5crypt($password).'';
						$change['userpassword'] = array($password);
					}else{
						set_message('Wrong current password.','error',1);
						$password_error = TRUE;
					}
				}

				if(!isset($password_error)){
					$modify = ldap_modify($ldap_connection_island, "uid=".$username.",".LDAP_PEOPLE.",".$organization.",".LDAP_TREE."", $change);
					
					if($modify)
						set_message('User edited successfully!','success',1);
					else
						set_message('Error to edit this user, try again.','error',1);
				}
			}
		}
		
		// Recover my account data
		$search_for = 'uid='.$_SESSION[''.SECURITY_SESSION.'']['username'].'';		
		$search = ldap_search($ldap_connection, "".$_SESSION[''.SECURITY_SESSION.'']['organization'].",".LDAP_TREE."", $search_for);  
		
		$ldapResults = ldap_get_entries($ldap_connection, $search);
		if($ldapResults['count'] < 1)
			Header("Location: index.php?page=logout");
		
		// Define form default values
		$username = ($ldapResults[0]['uid'][0] != $_POST['username'] && isset($_POST['username'])) ? $_POST['username'] : $ldapResults[0]['uid'][0];
		$name = ($ldapResults[0]['sn'][0] != $_POST['name'] && isset($_POST['name'])) ? $_POST['name'] : $ldapResults[0]['sn'][0];
		$email = ($ldapResults[0]['mail'][0] != $_POST['email'] && isset($_POST['email'])) ? $_POST['email'] : $ldapResults[0]['mail'][0];
		
		echo "<div id='text'>
				<a class='title'>My Account: ".$_SESSION[''.SECURITY_SESSION.'']['username']."</a>
			  </div>";
		
		echo "<form method='POST' action='' id='registration'>
				<table>
					<tr>
						<td>Login Name</td>
						<td><input type='text' name='username' value='".$username."' readonly/></td>
					</tr>
					
					<tr>
						<td>Full Name</td>
						<td><input type='text' name='name' value='".$name."'/></td>
					</tr>
					
					<tr>
						<td>E-mail</td>
						<td><input type='text' name='email' value='".$email."'/></td>
					</tr>
					
					<tr>
						<td>Current password</td>
						<td><input type='password' name='current_password'/></td>
					</tr>
					
					<tr>
						<td>New password</td>
						<td><input type='password' name='password'/></td>
					</tr>
					
					<tr>
						<td>Re-type password</td>
						<td><input type='password' name='password2'/></td>
					</tr>

					<tr>
						<td></td>
						<td><input type='submit' value='Apply changes' name='sbmt'/></td>
					</tr>
				</table>
			</form>";
	}
	
	function request_account(){
		require("mysql_connection.php");
		
		if(isset($_POST['sbmt'])){
			$username = $_POST['username'];
			$password = $_POST['password'];
			$password2 = $_POST['password2'];
			$name = $_POST['name'];
			$email = $_POST['email'];
			$institution = $_POST['institution'];
			
			if(empty($username) || empty($password) || empty($password2) || empty($name) || empty($institution))
				set_message('Fill out all fields to continue.','alert',1);
			else if($password != $password2)
				set_message('Passwords do not match.','alert',1);
			else{
				$ldap_server = mysql_query("SELECT `ldap_ip_address` FROM ".DB_SCHEDULER.".`islands` WHERE `institution` = '".$institution."'") or print_r(mysql_error());
				$ldap_server = mysql_fetch_object($ldap_server);
				
				$ldap_connection = ldap_connect($ldap_server->ldap_ip_address,PORT_LDAP) or die("Error connecting to the LDAP server");
				
				ldap_set_option($ldap_connection, LDAP_OPT_PROTOCOL_VERSION, 3);
				ldap_set_option($ldap_connection, LDAP_OPT_REFERRALS, 0);
				
				if ($ldap_connection) {
					$search_for = 'uid='.$username.'@'.$institution.'';
					
					$organization = "o=".$institution."";
					$organization = str_replace(".br","",$organization);
					
					$ldap_bind = ldap_bind($ldap_connection, ISLAND_USER_LDAP, ISLAND_PASS_LDAP);
					
					$search = ldap_search($ldap_connection, "".LDAP_PEOPLE.",".$organization.",".LDAP_TREE."", $search_for);  

					if(ldap_count_entries($ldap_connection, $search)){
						set_message('There is already a registered user with this Login Name.','error',1);
					}else{
						$search_max_uid = ldap_search($ldap_connection, "".LDAP_PEOPLE.",".$organization.",".LDAP_TREE."", "uid=*");
						$ldapResults = ldap_get_entries($ldap_connection, $search_max_uid);
						
						$max_uidn = 0;
						for ($item = 0; $item < $ldapResults['count']; $item++) {
							if($ldapResults[$item]['uidnumber'][0] > $max_uidn) $max_uidn = $ldapResults[$item]['uidnumber'][0];
						}
						
						if($max_uidn < 1500) $max_uidn = 1501; else $max_uidn++;
						
						$password = '{CRYPT}'.md5crypt($password).'';
						
						// Search group id:
						$search_group = ldap_search($ldap_connection, "".LDAP_GROUP.",".$organization.",".LDAP_TREE."", "cn=".$institution."");  
						$group_results = ldap_get_entries($ldap_connection, $search_group);
						
						$group_id = $group_results[0]['gidnumber'][0];
						
						// Creating user
						$data = array('cn' => $username,
									  'gidnumber' => $group_id,
									  'homedirectory' => '/home/'.$institution.'/'.$username.'',
									  'objectClass' => array('top','person','inetOrgPerson','posixAccount','eduPerson','brPerson','schacPersonalCharacteristics','fibre'),
									  'sn' => $name,
									  'uidnumber' => $max_uidn,
									  'uid' => ''.$username.'@'.$institution.'',
									  'eduPersonPrincipalName' => ''.$username.'@'.$institution.'',
									  'mail' => $email,
									  'userpassword' => ''.$password.'',
									  'loginShell' => '/bin/bash',
									  'userEnable' => 'FALSE',
									  'omfAdmin' => 'FALSE');
									  
						$add_user = ldap_add($ldap_connection, "uid=".$data["uid"].",".LDAP_PEOPLE.",".$organization.",".LDAP_TREE."", $data);
						
						if($add_user){
							// Send email to administrators
							$search_admin = ldap_search($ldap_connection, "".LDAP_PEOPLE.",".$organization.",".LDAP_TREE."", "omfadmin=TRUE"); 
							$admin_results = ldap_get_entries($ldap_connection, $search_admin);
							
							$subject = 'Testbed user registration';
							$message = 'You have a new user to be evaluated in the testbed:<br><br>';
							$message .= '<b>Name:</b> '.$name.'<br>';
							$message .= '<b>E-mail:</b> '.$email.'<br>';
							$message .= '<b>Institution:</b> '.$institution.'';
							
							$sender = array('email' => $email, 'name' => $name);
							
							$receiver = array();
							for ($i = 0; $i < $admin_results['count']; $i++) {
								$receiver[] = array('email' => $admin_results[$i]['mail'][0],
													'name' => $admin_results[$i]['sn'][0]);
							}

							if(count($receiver) > 0)
								send_mail($sender, $receiver, $subject, $message);
						}else
							set_message('Error in the Registration Request, try again.','error',1);
					}
				}
			}
		}
		
		$query = mysql_query("SELECT * FROM ".DB_SCHEDULER.".`islands` ORDER BY `institution` ASC");
		
		echo "<div id='text'>
				<a class='title'>Request Account</a>
			  </div>";
			  
		if($add_user)
			set_message('Request Registration was successful, wait for the approval of registration by administrators.','success',1);
		else{
			echo "<form method='POST' action='' id='registration'>
					<table>
						<tr>
							<td>Login Name</td>
							<td><input type='text' name='username' value='".$username."'/></td>
						</tr>
						
						<tr>
							<td>Full Name</td>
							<td><input type='text' name='name' value='".$name."'/></td>
						</tr>
						
						<tr>
							<td>E-mail</td>
							<td><input type='text' name='email' value='".$email."'/></td>
						</tr>
						
						<tr>
							<td>Institution</td>
							<td>
								<select name='institution'>
									<option value=''>[Select Institution]</option>
								";
									while($results = mysql_fetch_object($query)){
										if($institution == $results->institution)
											echo '<option value="'.$results->institution.'" selected>('.strtoupper($results->institution).') '.utf8_encode($results->name).'</option>';
										else
											echo '<option value="'.$results->institution.'">('.strtoupper($results->institution).') '.utf8_encode($results->name).'</option>';
									}
								echo "
								</select>
							</td>
						</tr>
						
						<tr>
							<td>Password</td>
							<td><input type='password' name='password'/></td>
						</tr>
						<tr>
							<td>Re-type Password</td>
							<td><input type='password' name='password2'/></td>
						</tr>
						<tr>
							<td></td>
							<td><input type='submit' value='Request Account' name='sbmt'/></td>
						</tr>
					</table>
				</form>";
		}
	}

	function manager_island(){
		require("mysql_connection.php");
		
		if(isset($_POST['remove'])){
			$remove = mysql_query("DELETE FROM `".DB_SCHEDULER."`.`islands` WHERE `institution` = '".$_POST['institution']."'") or print_r(mysql_error());
			
			if($remove)
				set_message('Island success removed!','success',1);
			else
				set_message('Error to remove this island, try again.','error',1);
		}
		
		echo "<div id='text'>
				<a class='title'>Manager islands</a>
			</div>";
			
		echo "<div class='button'><a href='?page=add_island'>Add new island</a></div>";
			
		$query = mysql_query("SELECT * FROM `".DB_SCHEDULER."`.`islands`") or print_r(mysql_error());
			
		echo "<table id='reserve' class='table_max'>
				<tr class='top'>
					<td>Institution identifier</td>
					<td>MySQL server IP address</td>
					<td>Scheduler database</td>
					<td>Inventory database</td>
					<td>LDAP server IP address</td>
					<td width='120px'>Actions</td>
				</tr>";
		
		while($results = mysql_fetch_object($query)){
			echo "<tr>
				<td>".$results->institution."</td>
				<td>".$results->ip_address."</td>
				<td>".$results->scheduler_db."</td>
				<td>".$results->inventory_db."</td>
				<td>".$results->ldap_ip_address."</td>
				<td>
					<form action='' method='GET' style='display: inline;'>
						<input type='submit' value='Edit'>
						<input type='hidden' name='page' value='edit_island'>
						<input type='hidden' name='institution' value='".$results->institution."'>
					</form>
					<form action='' method='POST' style='display: inline;'>
						<input type='submit' name='remove' value='Remove'>
						<input type='hidden' name='institution' value='".$results->institution."'>
					</form>
				</td>
			</tr>";
		}
		
		echo "</table>";
	}
	
	function add_island(){
		require("mysql_connection.php");
		
		if(isset($_POST['submit'])){
			$acronym			=	$_POST['acronym'];
			$name				=	utf8_decode($_POST['name']);
			$ip_address			=	$_POST['ip_address'];
			$scheduler_db		=	$_POST['scheduler_db'];
			$inventory_db		=	$_POST['inventory_db'];
			$ldap_ip_address	=	$_POST['ldap_ip_address'];
			
			$search = mysql_query("SELECT * FROM `".DB_SCHEDULER."`.`islands` WHERE `institution` = '".$acronym."'") or print_r(mysql_error());
			
			if(!mysql_num_rows($search)){
				$insert = mysql_query("INSERT INTO `".DB_SCHEDULER."`.`islands` (`institution`,`name`,`ip_address`,`scheduler_db`,`inventory_db`,`ldap_ip_address`) VALUES ('".$acronym."', '".$name."', '".$ip_address."', '".$scheduler_db."', '".$inventory_db."','".$ldap_ip_address."')") or print_r(mysql_error());
				
				if($insert)
					set_message('Island added successfully!','success',1);
				else
					set_message('Error to add this island, try again.','error',1);
			}else{
				set_message('Sorry, this island already exist.','error',1);
			}
		}
		
		if(!isset($scheduler_db)) $scheduler_db = "scheduler";
		if(!isset($inventory_db)) $inventory_db = "inventory";
		
		echo "<div id='text'>
				<a class='title'>Add new island</a>
			</div>";
		
		echo "<form method='POST' action='' id='registration'>
				<table>
					<tr>
						<td>Institution identifier</td>
						<td><input type='text' name='acronym' value='".$acronym."'/></td>
						<td>Ex: ufg.br</td>
					</tr>
					
					<tr>
						<td>Institution name</td>
						<td><input type='text' name='name' value='".utf8_encode($name)."'/></td>
						<td></td>
					</tr>
					
					<tr>
						<td>MySQL server IP address</td>
						<td><input type='text' name='ip_address' value='".$ip_address."'/></td>
						<td></td>
					</tr>
					
					<tr>
						<td>Scheduler database name</td>
						<td><input type='text' name='scheduler_db' value='".$scheduler_db."'/></td>
						<td>Default: scheduler</td>
					</tr>
					
					<tr>
						<td>Inventory database name</td>
						<td><input type='text' name='inventory_db' value='".$inventory_db."'/></td>
						<td>Default: inventory</td>
					</tr>
					
					<tr>
						<td>LDAP server IP address</td>
						<td><input type='text' name='ldap_ip_address' value='".$ldap_ip_address."'/></td>
						<td></td>
					</tr>
					
					<tr>
						<td></td>
						<td><input type='submit' value='Add Island' name='submit'/></td>
						<td></td>
					</tr>
				</table>
			</form>";
	}
	
	function edit_island(){
		if(!isset($_GET['institution']))
			Header("Location: index.php");
			
		require("mysql_connection.php");
		
		if(isset($_POST['submit'])){
			$acronym			=	$_POST['acronym'];
			$name				=	utf8_decode($_POST['name']);
			$ip_address			=	$_POST['ip_address'];
			$scheduler_db		=	$_POST['scheduler_db'];
			$inventory_db		=	$_POST['inventory_db'];
			$ldap_ip_address	=	$_POST['ldap_ip_address'];
			
			$edit = mysql_query("UPDATE `".DB_SCHEDULER."`.`islands` SET `name` = '".$name."', `ip_address` = '".$ip_address."', `scheduler_db` = '".$scheduler_db."', `inventory_db` = '".$inventory_db."', `ldap_ip_address` = '".$ldap_ip_address."' WHERE `institution` = '".$acronym."'") or print_r(mysql_error());
				
			if($edit)
				set_message('Island edited successfully!','success',1);
			else
				set_message('Error to edit this island, try again.','error',1);
		}
		
		$query = mysql_query("SELECT * FROM `".DB_SCHEDULER."`.`islands` WHERE `institution` = '".$_GET['institution']."'") or print_r(mysql_error());
		$data = mysql_fetch_object($query);
		
		echo "<div id='text'>
				<a class='title'>Edit island (".strtoupper($data->institution).")</a>
			</div>";
		
		echo "<form method='POST' action='' id='registration'>
				<table>
					<tr>
						<td>Institution identifier</td>
						<td><input type='text' name='acronym' value='".$data->institution."' readonly/></td>
						<td>Ex: ufg.br</td>
					</tr>
					
					<tr>
						<td>Institution name</td>
						<td><input type='text' name='name' value='".utf8_encode($data->name)."'/></td>
						<td></td>
					</tr>
					
					<tr>
						<td>MySQL server IP address</td>
						<td><input type='text' name='ip_address' value='".$data->ip_address."'/></td>
						<td></td>
					</tr>
					<tr>
						<td>Scheduler database name</td>
						<td><input type='text' name='scheduler_db' value='".$data->scheduler_db."'/></td>
						<td>Default: scheduler</td>
					</tr>
					
					<tr>
						<td>Inventory database name</td>
						<td><input type='text' name='inventory_db' value='".$data->inventory_db."'/></td>
						<td>Default: inventory</td>
					</tr>
					
					<tr>
						<td>LDAP server IP address</td>
						<td><input type='text' name='ldap_ip_address' value='".$data->ldap_ip_address."'/></td>
						<td></td>
					</tr>
					
					<tr>
						<td></td>
						<td><input type='submit' value='Edit Island' name='submit'/></td>
						<td></td>
					</tr>
				</table>
			</form>";
	}
	
	function forgot_password(){
		require("mysql_connection.php");
		if(isset($_POST['sbmt'])){
			$username = $_POST['username'];
			$institution = $_POST['institution'];

			if(!strstr($username,"@".$institution."")){
				$username = "".$username."@".$institution."";
				$organization = "o=".$institution."";
			}else{
				$institution = substr($username, strpos($username, "@")+1);
				$organization = "o=".substr($username, strpos($username, "@")+1)."";
			}
			
			$organization = str_replace(".br","",$organization);

			$ldap_connection = ldap_connect(HOST_LDAP,PORT_LDAP) or die("Error connecting to the LDAP server");
			
			ldap_set_option($ldap_connection, LDAP_OPT_PROTOCOL_VERSION, 3);
			ldap_set_option($ldap_connection, LDAP_OPT_REFERRALS, 0);
			
			$search_for = "uid=".$username."";	
			$search = ldap_search($ldap_connection, "".LDAP_PEOPLE.",".$organization.",".LDAP_TREE."", $search_for); 
				
			if(ldap_count_entries($ldap_connection, $search)){
				$ldapResults = ldap_get_entries($ldap_connection, $search);
				
				$ldap_server = mysql_query("SELECT `ldap_ip_address` FROM ".DB_SCHEDULER.".`islands` WHERE `institution` = '".$institution."'") or print_r(mysql_error());
				$ldap_server = mysql_fetch_object($ldap_server);
					
				$ldap_connection_island = ldap_connect($ldap_server->ldap_ip_address,PORT_LDAP) or die("Error connecting to the LDAP server of island");
					
				ldap_set_option($ldap_connection_island, LDAP_OPT_PROTOCOL_VERSION, 3);
				ldap_set_option($ldap_connection_island, LDAP_OPT_REFERRALS, 0);
					
				$ldap_bind = ldap_bind($ldap_connection_island, ISLAND_USER_LDAP, ISLAND_PASS_LDAP);
				
				// Generate a new password and change it
				$new_password = substr(md5(uniqid(time(), true)), 0, 12);
				$crypted_password = '{CRYPT}'.md5crypt($new_password).'';
				$change['userpassword'] = array($crypted_password);

				$modify = ldap_modify($ldap_connection_island, "uid=".$username.",".LDAP_PEOPLE.",".$organization.",".LDAP_TREE."", $change);
				
				if($modify){
					// Send e-mail to the user
					$subject = 'Testbed password recovery';
					$message = 'You requested a password recovery in testbed.<br>'.
							   'New password: <b>'.$new_password.'</b>';
					
					$receiver[0] = array('email' => $ldapResults[0]['mail'][0],
										 'name' => $ldapResults[0]['sn'][0]);
									
					$sender = array('email' => $ldapResults[0]['mail'][0],
									'name' => $ldapResults[0]['sn'][0]);
										  
					send_mail($sender, $receiver, $subject, $message);
					set_message('Password changed successfully, please check your email to learn your new password','success',1);
				}else
					set_message('An error occurred, please try again','error',1);
			}else
				set_message('User not found.','error',1);	
		}
		
		$query = mysql_query("SELECT * FROM ".DB_SCHEDULER.".`islands` ORDER BY `institution` ASC");
		
		echo "<div id='text'>
				<a class='title'>Recover a forgotten password</a>
			  </div>";
		
		echo "<form method='POST' action='' id='registration'>
				<table>
					<tr>
						<td>Login Name</td>
						<td><input type='text' name='username'/></td>
					</tr>
					<tr>
						<td>Institution</td>
						<td>
							<select name='institution'>
								<option value='' selected>[Select Institution]</option>
							";
								while($resultado = mysql_fetch_object($query)){
									echo '<option value="'.$resultado->institution.'">('.strtoupper($resultado->institution).') '.utf8_encode($resultado->name).'</option>';
								}
							echo "
							</select>
						</td>
					</tr>
					<tr>
						<td></td>
						<td><input type='submit' value='Recover' name='sbmt'/></td>
					</tr>
				</table>
			</form>";
	}
	
	function logout(){
		session_unset();
		header("Location: index.php");
	}
?>
